﻿@using Abp.Extensions

@section Scripts{
    <script>
        !function ($) {

            var $$$ = function () {
                this.$box = $('.box');
                this.$table = $('.table');
                this.service = abp.services.app.message;
                this.localize = abp.localization.localize;
            };
            $$$.prototype = {
                init: function () {
                    this.initTable();
                },
                initTable: function () {
                    var self = this;
                    self.$table.bootstrapTable({
                        toggle: "table",
                        striped: true,
                        showColumns: true,
                        showRefresh: true,
                        pagination: true,
                        keyEvents: true,
                        sortable: false,
                        advancedSearch: false,
                        idTable: "advancedTable",
                        sidePagination: 'server',
                        pageNumber: 1,
                        pageSize: 10,
                        pageList: [10, 25, 50, 100, 200],
                        dataField: "items",
                        totalField: "totalCount",
                        queryParams: function (params) {
                            var result = {
                                skipCount: params.offset,
                                maxResultCount: params.offset + params.limit
                            };
                            return $.extend(result, params.predicate || {});
                        },
                        ajax: function (params) {
                            abp.ui.setBusy(self.$box);
                            self.service.getAll(params.data)
						        .done(params.success)
                                .fail(params.error)
						        .always(function () {
						            abp.ui.clearBusy(self.$box);
						        });
                            return params;
                        },
                        uniqueId: "id",
                        columns: [
                            {
                                title: self.localize("SerialNumber"),
                                formatter: function (value, row, index) { return index + 1; },
                                width: '30px'
                            },
                            {
                                field: '@("Title".ToCamelCase())',
                                title: self.localize("MessageTitle")
                            },
                            {
                                field: '@("Content".ToCamelCase())',
                                title: self.localize("MessageContent")
                            },
                            {
                                field: '@("SendTime".ToCamelCase())',
                                title: self.localize("MessageSendTime")
                            }
                        ]
                    });
                }
            };

            $(function () { (new $$$()).init(); });
        }(jQuery);
    </script>
}

<ul class="content-nav">
    <li class="active">
        <a href="javascript:;">@L("List")</a>
    </li>
    <li>
        <a href="@Url.Action("add")">@L("PublishMessage")</a>
    </li>
</ul>
<div class="box box-success box-edge-all" data-dock="true">
    <table class="table"></table>
</div>